// pages/minemodule/mine/mine.ts
const app = getApp()  // 获取App实例
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isqiye: false,
    nohead: app.getImgUrl('nohead.png'),  // 调用App实例上的方法
    lv: app.getImgUrl('lv.png'),  // 调用App实例上的方法
    jiqi: app.getImgUrl('jiqi.png'),  // 调用App实例上的方法
    list: [{
      img: app.getImgUrl('s1.png'),
      title1: "服务器",
      title2: "私人服务器部署",
      link: "/pages/myserver/myserver",
    }, {
      img: app.getImgUrl('s2.png'),
      title1: "个人仓库",
      title2: "仓库资源管理",
      link: "/pages/minemodule/Personalwarehouse/Personalwarehouse"
    }, {
      img: app.getImgUrl('s3.png'),
      title1: "维修报价",
      title2: "近期报价统计",
      link: "/pages/client/repair_price/index",
    }, {
      img: app.getImgUrl('s4.png'),
      title1: "运营中心",
      title2: "一站式企业管理",
      link: "/pages/operation-center/index/index",
    }, {
      img: app.getImgUrl('s5.png'),
      title1: "远存储",
      title2: "系统时间轴",
      link: "/pages/cloudStorage/index/index",
    }, {
      img: app.getImgUrl('s6.png'),
      title1: "多屏投显",
      title2: "视频投显到大屏",
      link: "/pages/display/index",
    }, {
      img: app.getImgUrl('s7.png'),
      title1: "运行记录",
      title2: "系统时间轴",
      link: "/pages/device/deviceLog/index",
    }, {
      img: app.getImgUrl('s8.png'),
      title1: "问题反馈",
      title2: "服务支持",
      link: "/pages/problemfeedback/problemfeedback",
    }, {
      img: app.getImgUrl('s9.png'),
      title1: "关于我们",
      title2: "了解更多",
      link: "/pages/aboutus/aboutus",
    },],
    isqiye: null,
    userdata: {},
  },
  onShow() {
    // 每次页面显示都会执行
    console.log('页面显示')
    this.getperson()
    // 这里适合做数据刷新等操作
  },
  onLoad() {
  },
  gopage: function (event) {
    // 获取传递的数据
    const item = event.currentTarget.dataset.item;
    console.log(item.link)
    wx.navigateTo({
      url: item.link
    })
  },
  async getperson() {
    console.log(app.globalData.session.zzstatus)
    //zzstatus  1企业用户，2客户
    if (app.globalData.session.zzstatus == 2) {
      this.setData({
        isqiye: false
      })
    } else {
      this.setData({
        isqiye: true
      })
    }

    let res = await app.axios(
      'user',
      {
        op: "ajaxUserSets",
        "zqstatus": app.globalData.session.zzstatus,
      },
      false
    )
    let items = res.item
    items.phones = this.formatPhone(items.phone)
    this.setData({
      userdata: items
    })
  },
  formatPhone: function (phone) {
    return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
    // return phones.slice(0, 3) + '**' + phone.slice(-4);
  },
  // 跳转个人资料页面
  gomember() {
    wx.navigateTo({
      url: '/pages/minemodule/personalData/personalData'
    })
  },
  // 跳转服务商页面
  goserver() {
    wx.navigateTo({
      url: '/pages/client/business_card/index'
    })
  },
  gohuiyuan() {
    wx.navigateTo({
      url: '/pages/minemodule/member/member'
    })
  },
  goPersonalCard() {
    wx.navigateTo({
      url: '/pages/minemodule/personal_card/index'
    })
  }
})